home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SunSoft Catalyst CDWARE 1996 May to August
/
Catalyst CDWARE 1996 May to August.iso
/
.products
/
JavaWorld
/
javaworld
/
cgi-bin
/
jw-adsales.cgi.old
< prev
next >
Wrap
Text File
|
1996-02-27
|
8KB
|
255 lines
#!/usr/local/bin/perl
# jw-adsales.cgi - script to process e-mail sent from JavaWorld.
# this is a kludge until the html mailto becomes ubiquitous.
#
# usage: jw-adsales.cgi <recipient> [ <return href> <return tag> | send ]
#
# if 'send' is the last command-line argument, jw-adsales.cgi assumes
# that it is to send the enclosed datastream to the recipient denoted by
# the first command-line argument. otherwise, it interprets the second
# and third command-line arguments as a return href and tag for 'back-to'
# functionality.
#
# it's fairly crucial that the e-mail address does not contain +
# signs, as this will confuse jw-adsales.cgi's interpretation of
# command-line arguments.
#
# complain to david.burnette@javaworld.com if there are problems.
if ("$ARGV[$#ARGV]" eq "send") { # catch message from first run of jw-adsales.cgi
$defaultfrom="javaworld\@javaworld.com";
$defaultname="JavaWorld";
$mailprog="/usr/lib/sendmail";
$bcc="jwbcc\@javaworld.com"; # recipient of failsafe copy
$bccname="JW bcc";
$bccsubject="bccmail to $ARGV[0]";
$date=`date`; chop($date);
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (@ARGV == 1) {
$recipient="david.burnette\@javaworld.com";
$href1="/javaworld/index.html";
$src1="/javaworld/icons/b-thismonth.gif";
$alt1="[This month's table of contents]";
}
elsif (@ARGV == 2) {
$recipient="$ARGV[0]";
$href1="/javaworld/index.html";
$src1="/javaworld/icons/b-thismonth.gif";
$alt1="[This month's table of contents]";
}
elsif (@ARGV == 3) {
$recipient="$ARGV[0]";
$href1="$ARGV[1]";
$src1="/javaworld/icons/b-thismonth.gif";
$alt1="[This month's table of contents]";
}
else {
$recipient="$ARGV[0]";
$href1="/javaworld/index.html";
$src1="/javaworld/icons/b-thismonth.gif";
$alt1="[This month's table of contents]";
$href2="$ARGV[1]#$ARGV[2]";
$src2="/javaworld/icons/b-backtostory.gif";
$alt2="[Back to story]";
}
$HREF1="<A HREF=\"$href1\"><IMG SRC=\"$src1\" ALT=\"$alt1\"></A>";
if (defined($href2)) {
$HREF2="<A HREF=\"$href2\"><IMG SRC=\"$src2\" ALT=\"$alt2\"></A>";
}
# Split the name-value pairs
@pairs = split(/&/,$buffer);
foreach $pair (@pairs)
{
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;
}
# check for empty message; thwart bastards
if ($FORM{'name'} =~ /^[\s]*$/
|| $FORM{'title'} =~ /^[\s]*$/
|| $FORM{'company'} =~ /^[\s]*$/
|| $FORM{'address'} =~ /^[\s]*$/
|| ($FORM{'phone'} =~ /^[\s]*$/ && $FORM{'email'} =~ /^[\s]*$/)
|| $FORM{'message'} =~ /^[\s]*$/) {
print <<END_OF_FORM;
Content-TYPE: text/html
<HTML>
<HEAD><TITLE>JavaWorld-Adsales E-mail Form</TITLE></HEAD>
<BODY>
<H3>
An empty message cannot be sent. It must contain a name, title,
company, phone, e-mail or postal address, and a message.
<P>
To send a message, return to the mail form by hitting your browser\'s
back button.
</H3>
</BODY>
</HTML>
END_OF_FORM
}
else { # send thank-you note to browser
print "Content-TYPE: text/html\n\n";
print "<HTML>\n";
print "<HEAD><TITLE>JavaWorld</TITLE></HEAD>\n";
print "<BODY>\n";
print "$HREF1$HREF2\n";
print "<H3>Thank you for sending mail to $recipient. We appreciate your patronage.</H3>\n";
print "</BODY>\n";
print "</HTML>\n";
# send failsafe copy of raw data to bcc
open (MAIL, "|$mailprog $bcc") || die "Can't open $mailprog!\n";
print MAIL "From: $bcc ($bccname)\n";
print MAIL "To: $bcc\n";
print MAIL "Subject: $bccsubject\n\n";
print MAIL "BEGIN RECORD $date\n";
print MAIL "recipient=$recipient\n";
print MAIL "href1=$href1\n";
print MAIL "src1=$src1\n";
print MAIL "alt1=$alt1\n";
print MAIL "href2=$href2\n";
print MAIL "src2=$src2\n";
print MAIL "alt2=$alt2\n";
print MAIL "CONTENT_LENGTH=$ENV{'CONTENT_LENGTH'}\n";
print MAIL "CONTENT_TYPE=$ENV{'CONTENT_TYPE'}\n";
print MAIL "DOCUMENT_ROOT=$ENV{'DOCUMENT_ROOT'}\n";
print MAIL "GATEWAY_INTERFACE=$ENV{'GATEWAY_INTERFACE'}\n";
print MAIL "HTTP_REFERER=$ENV{'HTTP_REFERER'}\n";
print MAIL "HTTP_USER_AGENT=$ENV{'HTTP_USER_AGENT'}\n";
print MAIL "QUERY_STRING=$ENV{'QUERY_STRING'}\n";
print MAIL "REMOTE_ADDR=$ENV{'REMOTE_ADDR'}\n";
print MAIL "REMOTE_HOST=$ENV{'REMOTE_HOST'}\n";
print MAIL "REQUEST_METHOD=$ENV{'REQUEST_METHOD'}\n";
print MAIL "SCRIPT_NAME=$ENV{'SCRIPT_NAME'}\n";
print MAIL "SERVER_NAME=$ENV{'SERVER_NAME'}\n";
print MAIL "SERVER_PORT=$ENV{'SERVER_PORT'}\n";
print MAIL "SERVER_PROTOCOL=$ENV{'SERVER_PROTOCOL'}\n";
print MAIL "SERVER_SOFTWARE=$ENV{'SERVER_SOFTWARE'}\n";
print MAIL "ARGV=@ARGV\n";
print MAIL "STDINDATA=$buffer\n";
print MAIL "END RECORD $date\n";
close(MAIL);
# send mail to $recipient
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "From: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "To: $recipient\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL "$FORM{'message'}\n";
print MAIL "\n------------------------------------------------------------\n\n";
print MAIL "Name: $FORM{'name'}\n";
print MAIL "Title: $FORM{'title'}\n";
print MAIL "Company: $FORM{'company'}\n";
@f = split(/\n/,$FORM{'address'});
print MAIL "Address: $f[0]\n";
shift(@f);
foreach $f (@f) {
print MAIL " $f[$f]\n";
}
print MAIL "Phone: $FORM{'phone'}\n";
print MAIL "E-mail: $FORM{'email'}\n\n";
print MAIL "E-mail from JavaWorld (http://www.javaworld.com)\n";
print MAIL "Agent: $ENV{'HTTP_USER_AGENT'}\n";
print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
print MAIL "HTTP_REFERER=$ENV{'HTTP_REFERER'}\n";
close(MAIL);
} # end of if bastard else sendmail
exit 0;
}
else { # present message form to browser
if (@ARGV == 0) {
$recipient="webmaster\@javaworld.com";
$href="/javaworld/index.html";
}
elsif (@ARGV == 1) {
$recipient="$ARGV[0]";
$href="/javaworld/index.html";
}
elsif (@ARGV == 2) {
$recipient="$ARGV[0]";
$href="$ARGV[1]";
}
else {
$recipient="$ARGV[0]";
$href="$ARGV[1]+$ARGV[2]";
}
$banner="Send mail to $recipient";
print <<END_OF_FORM;
Content-TYPE: text/html
<HTML>
<HEAD><TITLE>JavaWorld E-mail Form</TITLE></HEAD>
<BODY>
<FORM METHOD=POST ACTION="http://www.javaworld.com/cgi-bin/jw-adsales.cgi?$recipient+$href+send">
<P>
<BLOCKQUOTE>
<H2>For advertising information on <EM>JavaWorld</EM> call
or e-mail (using the form below) Colette McMullen, Associate Publisher,
colette.mcmullen\@javaworld.com, 415-267-4527.</H2>
</BLOCKQUOTE>
<P>
<STRONG>Your Name:</STRONG>
<INPUT TYPE="text" NAME="name" SIZE ="50">
<P>
<STRONG>Your Title:</STRONG>
<INPUT TYPE="text" NAME="title" SIZE ="50">
<P>
<STRONG>Your Company:</STRONG>
<INPUT TYPE="text" NAME="company" SIZE ="50">
<P>
<STRONG>Your Postal Address:</STRONG><BR>
<TEXTAREA COLS=50 ROWS=5 NAME="address"></TEXTAREA>
<P>
<STRONG>Your Phone:</STRONG>
<INPUT TYPE="text" NAME="phone" SIZE ="50">
<P>
<STRONG>Your e-mail address:</STRONG>
<INPUT TYPE="text" NAME="email" SIZE ="50">
<P>
<STRONG>Subject:</STRONG>
<INPUT TYPE="text" NAME="subject" SIZE ="50">
<P>
<STRONG>Please enter your message below:</STRONG><BR>
<TEXTAREA COLS=70 ROWS=10 NAME="message"></TEXTAREA>
<BR>
<INPUT TYPE="submit" VALUE="Send message">
<INPUT TYPE="reset" VALUE="Clear form"</P>
</FORM>
</BODY>
</HTML>
END_OF_FORM
exit 0;
}